﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Register.aspx.cs" Inherits="Register" meta:resourcekey="PageResource1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

</head>

<body>
    <form id="form1" runat="server">
        <div id=header>
            <asp:Panel ID="Panel1" runat="server" SkinID="topPanel" Height="71px"  meta:resourcekey="Panel2Resource1"></asp:panel>
        </div>
        <div id=main>
            
                <table cellspacing=4> 
                           <tr>
                            <td>
                                <asp:Label ID="labelLogin" runat="server" Text="Login:" SkinID="labelSkin" 
                                    meta:resourcekey="labelLoginResource1" ></asp:Label>
                                
                            </td>
                            <td>
                                <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager>    
                                <asp:TextBox ID="txtLogin"  runat="server" Width="166px" 
                                    meta:resourcekey="TextBox3Resource1"></asp:TextBox>                                
                                
                                       <asp:CustomValidator ID="loginValidator"                                         
                                                             runat="server" 
                                                             ControlToValidate="txtLogin"
                                                             Display="Dynamic" 
                                                             ClientValidationFunction="login_extists"                                                              
                                                             SkinID="customValidatorSkin">  
                                                             
                                        </asp:CustomValidator>

                                       <asp:RequiredFieldValidator ID="loginRequiredFieldValidator" 
                                                                   runat="server" 
                                                                   ControlToValidate="txtLogin"
                                                                   EnableClientScript="false" 
                                                                   Display="Dynamic"                                                                                                                                   
                                                                   SkinID="RequiredFieldValidatorSkin">
                                       </asp:RequiredFieldValidator>

                            </td>
                    
                        </tr>                    
                    
                <tr>
                <td>
                    <asp:Label ID="labelFirstName" runat="server" Text="First name:" 
                        SkinID="labelSkin" meta:resourcekey="labelFirstNameResource1"></asp:Label>
                    
                </td><td>
                <asp:TextBox ID="txtFirstName" runat="server" Width="166px" meta:resourcekey="TextBox7Resource1"></asp:TextBox>
                </td>
                   
                </tr>
                <tr>
                <td class="style2"> 
                <asp:Label ID="labelLastName" runat="server" Text="Last name:" SkinID="labelSkin" meta:resourcekey="labelLastNameResource1"></asp:Label>
                </td>
                <td>
                <asp:TextBox ID="txtLastName" runat="server" Width="166px" meta:resourcekey="TextBox8Resource1"></asp:TextBox>
                </td>
                </tr>
                   
                        <tr>
                            <td class="style2">
                                <asp:Label ID="labelPassword" runat="server" SkinID="labelSkin" Text="Password:" meta:resourcekey="labelPasswordResource1"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="166px" meta:resourcekey="TextBox4Resource1"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="passwordRequiredFieldValidator" 
                                                            runat="server" 
                                                            ControlToValidate="txtPassword" 
                                                            EnableClientScript="false" 
                                                            Display="Dynamic"
                                                            SkinID="RequiredFieldValidatorSkin">
                                 </asp:RequiredFieldValidator>
                            </td>
                        </tr>
                            <tr>
                                <td class="style2">
                                     <asp:Label ID="labelConfirmPassword" runat="server" SkinID="labelSkin" Text="Confirm password:" meta:resourcekey="labelConfirmPasswordResource1"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtConfirmPassword" runat="server" TextMode="Password" Width="166px" meta:resourcekey="TextBox5Resource1"></asp:TextBox>
                                    
                                    <asp:CompareValidator ID="passwordMatchValidator" 
                                                          runat="server" 
                                                          Display="Dynamic" 
                                                          EnableClientScript="true" 
                                                          ControlToCompare="txtPassword" 
                                                          ControlToValidate="txtConfirmPassword" 
                                                          SkinID="compareValidatorSkin">
                                    </asp:CompareValidator>       
                                             
                                    <asp:RequiredFieldValidator ID="confirmPasswordRequiredFieldValidator" 
                                                                runat="server" 
                                                                ControlToValidate="txtConfirmPassword" 
                                                                EnableClientScript="false" 
                                                                Display="Dynamic"
                                                                SkinID="RequiredFieldValidatorSkin">
                                    </asp:RequiredFieldValidator>
                                </td>
                            </tr>
                                <tr>
                                    <td class="style2">
                                        <asp:Label ID="labelEmail" runat="server" SkinID="labelSkin" Text="Email:" meta:resourcekey="labelEmailResource1"></asp:Label>
                                        
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtEmail" runat="server" Width="166px" meta:resourcekey="TextBox6Resource1"></asp:TextBox>
                                        <asp:RegularExpressionValidator ID="emailValidator" 
                                                                        runat="server" 
                                                                        Display="Dynamic" 
                                                                        EnableClientScript="true" 
                                                                        ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                                                                        ControlToValidate="txtEmail" 
                                                                        SkinID="emailValidatorSkin">
                                       </asp:RegularExpressionValidator>
                                        <asp:RequiredFieldValidator ID="emailRequiredFieldValidator" 
                                                                    runat="server" 
                                                                    ControlToValidate="txtEmail"
                                                                    EnableClientScript="false" 
                                                                    Display="Dynamic" 
                                                                    SkinID="RequiredFieldValidatorSkin">
                                        </asp:RequiredFieldValidator>
                                    </td>
                                </tr>
                                    <tr>
                                        <td class="style2">
                                            <asp:Label ID="labelPhone" runat="server" SkinID="labelSkin" Text="Phone:" meta:resourcekey="labelPhoneResource1"></asp:Label>                                            
                                        </td>
                                        <td>
                                            <asp:TextBox ID="txtPhone" runat="server" Width="166px" meta:resourcekey="TextBox9Resource1"></asp:TextBox>
                                         </td>
                                    </tr>
                   
                </table>
                

                <asp:Button ID="Button2" runat="server" onclick="btnCreateAccount_Click"   Text="Create" meta:resourcekey="Button2Resource1" />
            
</div>
  
  <div id=footer>
  
             <asp:LinkButton ID="Link_EN" runat="server" SkinID="linkbuttonSkin" meta:resourcekey="Link_ENResource1" onclick="Link_EN_Click" Text="LinkButton"></asp:LinkButton>
|
             <asp:LinkButton ID="Link_RU" runat="server" SkinID="linkbuttonSkin" meta:resourcekey="Link_RUResource1" onclick="Link_RU_Click" Text="LinkButton"></asp:LinkButton>
     </div>

<script type="text/javascript" language="javascript">
           
    function createXMLHttpRequest() {
       try { return new XMLHttpRequest(); } catch(e) {}
       try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
       try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
       alert("XMLHttpRequest not supported");
       return null;
    }

    function login_extists(source,arguments)
    {                     

      var strUrl ="http://localhost:17027/Deimos/chkUsr.ashx?name=" + arguments.Value;       
      
      var xmlHttpReq= createXMLHttpRequest();

      xmlHttpReq.open("GET", strUrl, false);
      xmlHttpReq.send(null);
    
      var yourJSString = xmlHttpReq.responseText;            

      if (yourJSString=="True")
      {
        arguments.IsValid=false;         

      }
      else
      {
        arguments.IsValid=true;         
      }

    }
    
</script>
   

    </form>

</body>


</html>
